import json


def generate_android_values(json_file, output_file):
    with open(json_file, 'r', encoding='utf-8') as f:
        data = json.load(f)

    with open(output_file, 'w', encoding='utf-8') as f:
        f.write('<?xml version="1.0" encoding="utf-8"?>\n')
        f.write('<resources>\n')

        for key, value in data.items():
            formatted_value = value.replace('\n', r'\n')
            f.write('    <string name="{0}">{1}</string>\n'.format(key, formatted_value))

        f.write('</resources>')


if __name__ == '__main__':
    json_file = 'room/string_zh_CN.json'
    output_file = 'values/strings-live.xml'
    generate_android_values(json_file, output_file)